package com.egao.orderB.service.impl;

import com.egao.common.core.damon.constant.UserConstant;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.orderB.mapper.BillProcessMapper;
import com.egao.orderB.entity.BillProcess;
import com.egao.orderB.service.BillProcessService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.egao.orderB.biz.BillProcessBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 订单流程状态服务实现类
 * @author : Doman
 * @date : 2020-06-17 09:37:30
 * @version ：1.0
 */
@Service
public class BillProcessServiceImpl /*extends ServiceImpl<BillProcessMapper, BillProcess> */implements BillProcessService {

	@Autowired
	private BillProcessBiz billProcessBiz;

    /**
    @Override
    public PageResult<BillProcess> listPage(PageParam<BillProcess> page) {
        List<BillProcess> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<BillProcess> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */
    @Override
    public JsonResult list(PageResult2<T> page, BillProcess billProcess, User loginUser)  throws Exception{
        return billProcessBiz.list(page,billProcess,loginUser);
    }

    @Override
    public JsonResult list(BillProcess billProcess, User loginUser) {
        return JsonResult.ok().setData(billProcessBiz.list(billProcess));
    }

    @Override
    public BillProcess getById(BillProcess billProcess) {
        return billProcessBiz.getById(billProcess);
    }

    @Override
    public JsonResult save(BillProcess billProcess, User loginUser) {
        billProcess.setOrganizationId(UserConstant.ORGANIZATION_ID +"");
        if (billProcessBiz.save(billProcess, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Override
    public JsonResult update(BillProcess billProcess, User loginUser) {
        if (billProcessBiz.update(billProcess, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(BillProcess billProcess, User loginUser) {
        if (billProcessBiz.remove(billProcess, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
